package io.github.biezhi.elves.utils;

import java.io.UnsupportedEncodingException;

import io.github.biezhi.elves.encrypt.Base64Encrypt;

/**
 * base64加密工具类
 *
 */
public class Base64Utils {
	/**
	 * base64编码
	 * @param encodeString	参数说明：要加密的字符串
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	public static String encodeBase64(String encodeString) throws UnsupportedEncodingException {
		return Base64Encrypt.UTF8.encodeBase64(encodeString);
	}
	
	/**
	 * base64解码
	 * @param dcodeString	参数说明：要解密的字符串
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	public static String decodeBase64(String dcodeString) throws UnsupportedEncodingException {
		return Base64Encrypt.UTF8.decodeBase64(dcodeString);
	}

	public static void main(String[] args) throws UnsupportedEncodingException {
		String testString = "ddd";
		String baseEncrypt = Base64Utils.encodeBase64(testString);
		System.out.println(baseEncrypt);
		System.out.println(Base64Utils.decodeBase64(baseEncrypt));
	}
}